package cn.ahpu.tools;

public class Operations {
	public static int add(Integer x,Integer y) {
		return x+y;
	}
	public static long add(Long x,Long y) {
		return x+y;
	}
	public static int sub(Integer y,Integer x) {
		return x-y;
	}
	public static long sub(Long y,Long x) {
		return x-y;
	}
	public static int mul(Integer x,Integer y) {
		return x*y;
	}
	public static long mul(Long x,Long y) {
		return x*y;
	}
	public static int div(Integer y,Integer x) {
		return x/y;
	}
	public static long div(Long y,Long x) {
		return x/y;
	}
	public static int sur(Integer x,Integer y) {
		return x%y;
	}
	public static long sur(Long x,Long y) {
		return x%y;
	}
	public static char intToOperationChar(Integer num) {
		char c = '=';
		switch(num) {
			case 0:c='+';break;
			case 1:c='-';break;
			case 2:c='*';break;
			case 3:c='/';break;
			default: c='=';
		}
		return c;
	}
	public static boolean judgeOperationChar(Integer num) {
		return num==2 || num==3;
	}
	public static int operate(Integer x,Integer y,Integer num) {
		int result = 0;
		switch(num) {
			case 0:result=Operations.add(x, y);break;
			case 1:result=Operations.sub(x, y);break;
			case 2:result=Operations.mul(x, y);break;
			case 3:result=Operations.div(x, y);break;
		}
		return result;
	}
	public static long operate(Long x,Long y,Integer num) {
		long result = 0;
		switch(num) {
			case 0:result=Operations.add(x, y);break;
			case 1:result=Operations.sub(x, y);break;
			case 2:result=Operations.mul(x, y);break;
			case 3:result=Operations.div(x, y);break;
		}
		return result;
	}
	/**
	 * 校验运算符，使其已经出现过的运算符尽量少出现
	 * @param num
	 */
	public static boolean judgeOperations(int x,int y) {
		return x!=y;
	}
}
